import axios from 'axios'
import MockAdapter from 'axios-mock-adapter'
import { requestConfig } from "@/setting"
import { set } from "lodash"
const getJson = function (data, total = 0) {
    data = { data, total }
    set(data, requestConfig.successProperty, requestConfig.successValue);
    return [200, data]
}

// 创建默认实例对象
// 拦截axios请求
const mock = new MockAdapter(axios, { delayResponse: 200 })

// 用户登录
mock.onAny('sess/login').reply(() => {
    return getJson({
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3NuIjoiMTUyMzQyMTYxODg1ODEyMDAxIiwicm9sZV90eXBlIjoxLCJvcmdfcHNuIjoiIiwiYXV0aG9yaXplX3RpbWUiOiIyMDIxLTEwLTAxIDA5OjQxOjQyIn0.uN9xweKAtckKEn6IPSdE2O0qdb3darjRXQZddlYlYfE",
        "role_type": 1,
        "org": [{ "full_name": "李四", "org_sn": "152342161885411001", "org_name": "系统管理员", "org_lxr": "张三", "org_tel": "13200132999", "factory_sn": "", "yard_sn": "" }]
    })
});

const accessData = [
    { "id": 3, label: '平台管理', path: '', type: 1, parentid: 0 },
    { "id": 31, label: '园区管理', path: 'parkTable', type: 1, parentid: 3 },
    { "id": 311, label: '新增', path: 'add', type: 3, parentid: 31 },
    { "id": 312, label: '编辑', path: 'edit', type: 3, parentid: 31 },
    { "id": 313, label: '删除', path: 'del', type: 3, parentid: 31 },
    { "id": 314, label: '查询', path: 'query', type: 3, parentid: 31 },
    { "id": 315, label: '管理', path: 'manage', type: 3, parentid: 31 },

    { "id": 32, label: '菜单权限', path: 'systemAccessHome', type: 1, parentid: 3 },
    { "id": 321, label: '新增', path: 'add', type: 3, parentid: 32 },
    { "id": 322, label: '编辑', path: 'edit', type: 3, parentid: 32 },
    { "id": 323, label: '删除', path: 'del', type: 3, parentid: 32 },
    { "id": 324, label: '查询', path: 'query', type: 3, parentid: 32 },

    { "id": 2, label: '管理小区', path: 'parkManagement', type: 2, parentid: 0 },

    { "id": 21, label: '园区', path: '', type: 1, parentid: 2 },
    { "id": 1, label: '园区资料', path: '', type: 1, parentid: 21 },

    { "id": 11, label: '角色管理', path: 'purviewRoleTable', type: 2, parentid: 1 },
    { "id": 111, label: '新增', path: 'add', type: 3, parentid: 11 },
    { "id": 112, label: '编辑', path: 'edit', type: 3, parentid: 11 },
    { "id": 113, label: '删除', path: 'del', type: 3, parentid: 11 },
    { "id": 114, label: '查询', path: 'query', type: 3, parentid: 11 },

    { "id": 12, label: '部门管理', path: 'purviewDepartmentHome', type: 2, parentid: 1 },
    { "id": 121, label: '新增', path: 'add', type: 3, parentid: 12 },
    { "id": 122, label: '编辑', path: 'edit', type: 3, parentid: 12 },
    { "id": 123, label: '删除', path: 'del', type: 3, parentid: 12 },
    { "id": 124, label: '查询', path: 'query', type: 3, parentid: 12 },

    { "id": 13, label: '员工管理', path: 'purviewStaffTable', type: 1, parentid: 1 },
    { "id": 131, label: '新增', path: 'add', type: 3, parentid: 13 },
    { "id": 132, label: '编辑', path: 'edit', type: 3, parentid: 13 },
    { "id": 133, label: '删除', path: 'del', type: 3, parentid: 13 },
    { "id": 134, label: '查询', path: 'query', type: 3, parentid: 13 },
    { "id": 135, label: '角色设置', path: 'role', type: 3, parentid: 13 },
    { "id": 136, label: '开卡', path: 'card', type: 3, parentid: 13 },
    { "id": 137, label: '销卡', path: 'cancel', type: 3, parentid: 13 },

    { "id": 14, label: '楼栋管理', path: 'parkBuildingTable', type: 1, parentid: 1 },
    { "id": 141, label: '新增', path: 'add', type: 3, parentid: 14 },
    { "id": 142, label: '编辑', path: 'edit', type: 3, parentid: 14 },
    { "id": 143, label: '删除', path: 'del', type: 3, parentid: 14 },
    { "id": 144, label: '查询', path: 'query', type: 3, parentid: 14 },
    { "id": 145, label: '新增房间', path: 'room', type: 3, parentid: 14 },

    { "id": 15, label: '楼层管理', path: 'parkFloorHome', type: 1, parentid: 1 },
    { "id": 151, label: '新增', path: 'add', type: 3, parentid: 15 },
    { "id": 152, label: '编辑', path: 'edit', type: 3, parentid: 15 },
    { "id": 153, label: '删除', path: 'del', type: 3, parentid: 15 },
    { "id": 154, label: '查询', path: 'query', type: 3, parentid: 15 },

    { "id": 16, label: '房间管理', path: 'parkRoomHome', type: 1, parentid: 1 },
    { "id": 161, label: '新增', path: 'add', type: 3, parentid: 16 },
    { "id": 162, label: '编辑', path: 'edit', type: 3, parentid: 16 },
    { "id": 163, label: '删除', path: 'del', type: 3, parentid: 16 },
    { "id": 164, label: '查询', path: 'query', type: 3, parentid: 16 },


    { "id": 40, label: '住户管理', path: '', type: 1, parentid: 21 },
    { "id": 41, label: '住户列表', path: 'parkTenantTable', type: 1, parentid: 40 },
    { "id": 411, label: '新增', path: 'add', type: 3, parentid: 41 },
    { "id": 412, label: '编辑', path: 'edit', type: 3, parentid: 41 },
    { "id": 414, label: '删除', path: 'del', type: 3, parentid: 41 },
    { "id": 414, label: '查询', path: 'query', type: 3, parentid: 41 },
    { "id": 425, label: '详情', path: 'info', type: 3, parentid: 41 },

    { "id": 42, label: '住户审核列表', path: 'parkTenantAuditTable', type: 1, parentid: 40 },
    { "id": 421, label: '审核', path: 'audit', type: 3, parentid: 42 },
    { "id": 422, label: '查询', path: 'query', type: 3, parentid: 42 },


    { "id": 51, label: '服务', path: '', type: 1, parentid: 2 },

    { "id": 511, label: '服务人员', path: 'servicesStaffTable', type: 1, parentid: 51 },
    { "id": 5111, label: '新增', path: 'add', type: 3, parentid: 511 },
    { "id": 5114, label: '删除', path: 'del', type: 3, parentid: 511 },
    { "id": 5114, label: '查询', path: 'query', type: 3, parentid: 511 },

    { "id": 512, label: '新闻公告', path: 'servicesNoticeTable', type: 1, parentid: 51 },
    { "id": 5121, label: '新增', path: 'add', type: 3, parentid: 512 },
    { "id": 5124, label: '删除', path: 'del', type: 3, parentid: 512 },
    { "id": 5124, label: '查询', path: 'query', type: 3, parentid: 512 },
    { "id": 5125, label: '编辑', path: 'edit', type: 3, parentid: 512 },

    { "id": 513, label: '活动报名', path: 'servicesActivityTable', type: 1, parentid: 51 },
    { "id": 5131, label: '新增', path: 'add', type: 3, parentid: 513 },
    { "id": 5134, label: '删除', path: 'del', type: 3, parentid: 513 },
    { "id": 5134, label: '查询', path: 'query', type: 3, parentid: 513 },
    { "id": 5135, label: '编辑', path: 'edit', type: 3, parentid: 513 },
    { "id": 5136, label: '详情', path: 'info', type: 3, parentid: 513 },

    { "id": 514, label: '掌上报修', path: 'servicesFixTable', type: 1, parentid: 51 },
    { "id": 5141, label: '详情', path: 'info', type: 3, parentid: 514 },
    { "id": 5142, label: '查询', path: 'query', type: 3, parentid: 514 },

    { "id": 515, label: '投诉建议', path: 'servicesFeedbackTable', type: 1, parentid: 51 },
    { "id": 5151, label: '详情', path: 'info', type: 3, parentid: 515 },
    { "id": 5152, label: '查询', path: 'query', type: 3, parentid: 515 },

    { "id": 61, label: '设备', path: '', type: 1, parentid: 2 },

    { "id": 611, label: '门禁管理', path: 'equipmentDoorHome', type: 1, parentid: 61 },
    { "id": 6111, label: '新增', path: 'add', type: 3, parentid: 611 },
    { "id": 6114, label: '删除', path: 'del', type: 3, parentid: 611 },
    { "id": 6114, label: '查询', path: 'query', type: 3, parentid: 611 },
    { "id": 6115, label: '编辑', path: 'edit', type: 3, parentid: 611 },
    { "id": 6116, label: '开门记录', path: 'log', type: 3, parentid: 611 },
    { "id": 6117, label: '远程操作', path: 'remote', type: 3, parentid: 611 },

    { "id": 613, label: '门禁组管理', path: 'equipmentDoorGroupTable', type: 1, parentid: 61 },
    { "id": 6131, label: '新增', path: 'add', type: 3, parentid: 613 },
    { "id": 6134, label: '删除', path: 'del', type: 3, parentid: 613 },
    { "id": 6134, label: '查询', path: 'query', type: 3, parentid: 613 },
    { "id": 6135, label: '编辑', path: 'edit', type: 3, parentid: 613 },
    { "id": 6136, label: '门禁设置', path: 'door', type: 3, parentid: 613 },


    { "id": 612, label: '门卡管理', path: 'equipmentCardTable', type: 1, parentid: 61 },
    { "id": 6121, label: '续期', path: 'renewal', type: 3, parentid: 612 },
    { "id": 6124, label: '注销', path: 'del', type: 3, parentid: 612 },
    { "id": 6124, label: '查询', path: 'query', type: 3, parentid: 612 },
    { "id": 6125, label: '启用/禁用', path: 'status', type: 3, parentid: 612 },


    { "id": 614, label: '监控管理', path: 'equipmentMonitorTable', type: 1, parentid: 61 },
    { "id": 6141, label: '新增', path: 'add', type: 3, parentid: 614 },
    { "id": 6142, label: '编辑', path: 'edit', type: 3, parentid: 614 },
    { "id": 6144, label: '删除', path: 'del', type: 3, parentid: 614 },
    { "id": 6144, label: '查询', path: 'query', type: 3, parentid: 614 },
    { "id": 6145, label: '查看', path: 'video', type: 3, parentid: 614 }

]

// 用户登录
// mock.onAny('sess/user-role').reply(() => {
//     return getJson(accessData)
// });

// 用户菜单
mock.onAny('role/menu').reply(() => {
    return getJson(accessData)
});

// 未关联住户管理
mock.onAny('uncorrelated/list').reply(() => {
    return getJson([{}])
});

// 其他请求按正常网络请求处理
mock.onAny().passThrough();